<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>CMS信息表</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="/resources/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="/resources/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <script src="/resources/js/echarts.min.js"></script>
    <link rel="stylesheet" href="/resources/css/amazeui.min.css"/>
    <link rel="stylesheet" href="/resources/css/amazeui.datatables.min.css"/>
    <link rel="stylesheet" href="/resources/css/app.css">
    <script src="/resources/js/jquery.min.js"></script>
    <%--<!--富文本编辑器-->--%>

    <link href="/resources/ueidtor/themes/default/css/ueditor.css" type="text/css" rel="stylesheet">
    <script type="text/javascript" src="/resources/ueidtor/third-party/jquery-1.10.2.js"></script>
    <script type="text/javascript" charset="utf-8" src="/resources/ueidtor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/resources/ueidtor/ueditor.all.js"></script>
    <script type="text/javascript" charset="utf-8" src="/resources/ueidtor/lang/zh-cn/zh-cn.js"></script>

</head>

<body data-type="widgets">

<script src="/resources/js/theme.js"></script>
<div class="am-g tpl-g">
    <%--头部开始--%>
    <%@include file="header.jsp" %>
    <%--头部结束--%>

    <!-- 内容区域 -->
    <div class="tpl-content-wrapper">


        <div class="row-content am-cf">

            <div class="row">

                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title am-fl"> App首页管理</div>
                            <div class="widget-function am-fr">
                                <a href="javascript:;" class="am-icon-cog"></a>
                            </div>
                        </div>

                        <div class="widget-body am-fr">

                            <form action="" class="am-form tpl-form-border-form" id="subForm">
                                <div class="am-form-group">
                                    <input class="am-hide" name="id" value="${app.id}">
                                    <label for="user-name" class="am-u-sm-12 am-form-label am-text-left"> 标题 <span
                                            class="tpl-form-line-small-title">Title</span></label>
                                    <div class="am-u-sm-12">
                                        <input type="text" name="title"  class="tpl-form-input am-margin-top-xs title"
                                               id="user-name" value="App首页内容"  placeholder="请输入标题文字" readonly>
                                        <small class="tipsTitle"></small>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                <!--富文本编辑器-->
                                <!--style给定宽度可以影响编辑器的最终宽度-->
                                <script name="content" type="text/plain" id="myEditor" style="width:1000px;height:300px;">
                                            ${app.content}
                                </script>
                                </script>
                                    <script type="text/javascript">
                                       var ue = UE.getEditor('myEditor');
                                        UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
                                        UE.Editor.prototype.getActionUrl = function(action) {
                                            if (action == 'uploadimage' || action == 'uploadscrawl' || action == 'uploadimage') {
                                                var host = location.host;
                                                return 'http://'+host+'/file/editorupload'; //在这里返回我们实际的上传图片地址
                                            } else {
                                                return this._bkGetActionUrl.call(this, action);
                                            }
                                        }
                                    </script>

                                </div>

                                <div class="am-form-group">
                                    <div class="am-u-sm-12 am-u-sm-push-12">
                                        <button id="subBtn" type="button"
                                                class="am-btn am-btn-primary tpl-btn-bg-color-success subBtn">
                                            更新
                                        </button>
                                        <%--<a href="/cmsController/showCmsInfoPage">新闻展示页</a>--%>
                                    </div>
                                </div>

                                <div class="am-form-group"></div>
                                <div class="am-form-group"></div>
                                <div class="am-form-group"></div>
                                <div class="am-form-group"></div>
                                <div class="am-form-group"></div>
                                <div class="am-form-group"></div>

                            </form>
                        </div>
                        </div>
                    </div>

                </div>

            </div>

        </div>
    </div>

    <script src="/resources/js/amazeui.min.js"></script>
    <script src="/resources/js/amazeui.datatables.min.js"></script>
    <script src="/resources/js/dataTables.responsive.min.js"></script>
    <script src="/resources/js/app.js"></script>
    <script>
        //编辑新闻(更新)
        $("#subBtn").on("click", function (){
            if (confirm("您确定更新当前移动端首页？")) {
                $.ajax({
                    type: "POST",
                    url: "/updateappinfo",
                    dataType: "json",
                    data: $('#subForm').serialize(),
                    success: function (data) {
                        console.log(data);
                        if (data.success) {
                            alert(data.msg);
                            window.location.reload();
                        } else {
                            alert(data.msg);
                        }
                    },
                    error: function () {
                        alert("发送请求失败！");
                    }
                });
            }else{
                alert("未更新!!!");
            }
        });

    </script>

</body>

</html>